package acs.bridge.dao;

import acs.bridge.model.bm_load_ch_way4_model;
import acs.bridge.model.bm_load_way4_model;
import org.springframework.jdbc.core.JdbcTemplate;

import java.math.BigDecimal;
import java.util.List;

/**
 * acs.bridge.dao
 * User: KuznetsovStV
 * Date: 24.06.13
 * Time: 16:26
 */
public class bm_load_way4DAOImpl {
    private JdbcTemplate jdbcTemplate;

    public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
        this.jdbcTemplate = jdbcTemplate;
    }

    public JdbcTemplate getJdbcTemplate() {
        return jdbcTemplate;
    }

    public void deleteTmpFile() {
        this.jdbcTemplate.update("delete from fbu_wm.fbi_tmp_way4");
    }

    public void deleteTmpFile_ch() {
        this.jdbcTemplate.update("delete from fbu_wm.fbi_tmp_ch_way4");
    }


    public void final_processing(BigDecimal taskID) {
        this.jdbcTemplate.update("{call fbu_wm.final_unv_file(?)}", new Object[]{taskID});
    }


    public void insertRawFile(bm_load_way4_model a_bm_loadway4_model) {
        this.jdbcTemplate.update("insert into fbu_wm.fbi_tmp_way4 (drn, orig_drn, prev_drn, term_id, card_number, oper_date,\n" +
                "       currency, amount, fee, rrn, authcode, good_code, quantity,\n" +
                "       src_price, base_price, trans_code, good_id,description,channel,transitcontractnumber,rest_quantity,country,city,location,commodity,tgt_cost_amount,discount_amount,repost_doc,summdrn) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", new Object[]{a_bm_loadway4_model.getDrn(), a_bm_loadway4_model.getOrig_drn(), a_bm_loadway4_model.getPrev_drn(), a_bm_loadway4_model.getTerm_id(), a_bm_loadway4_model.getCard_number(), a_bm_loadway4_model.getOper_date(), a_bm_loadway4_model.getCurrency(), a_bm_loadway4_model.getAmount(), a_bm_loadway4_model.getFee(), a_bm_loadway4_model.getRrn(), a_bm_loadway4_model.getAuthcode(), a_bm_loadway4_model.getGood_code(), a_bm_loadway4_model.getQuantity(), a_bm_loadway4_model.getSrc_price(), a_bm_loadway4_model.getBase_price(), a_bm_loadway4_model.getTrans_code(), a_bm_loadway4_model.getGood_id(), a_bm_loadway4_model.getDescription(), a_bm_loadway4_model.getChannel(), a_bm_loadway4_model.getTransitContractNumber(), a_bm_loadway4_model.getRest_quantity(), a_bm_loadway4_model.getCountry(), a_bm_loadway4_model.getCity(), a_bm_loadway4_model.getLocation(), a_bm_loadway4_model.getCommodity(), a_bm_loadway4_model.getTgt_cost_amount(), a_bm_loadway4_model.getDiscount_amount(), a_bm_loadway4_model.getRepost_doc(), a_bm_loadway4_model.getSummdrn()});
    }


    public void insertRawFile_ch(bm_load_ch_way4_model a_bm_loadway4_model) {
        this.jdbcTemplate.update("insert into fbu_wm.fbi_tmp_ch_way4 (drn, rrn, authcode, pm_online, requestcategory, localdt,\n" +
                "       transitcontractnumber, contractnumber,amount,channel,orig_drn,rest_amount) values (?,?,?,?,?,?,?,?,?,?,?,?)", new Object[]{a_bm_loadway4_model.getDrn(), a_bm_loadway4_model.getRrn(), a_bm_loadway4_model.getAuthcode(), a_bm_loadway4_model.getPm_online(), a_bm_loadway4_model.getRequestcategory(), a_bm_loadway4_model.getLocaldt(), a_bm_loadway4_model.getTransitcontractnumber(), a_bm_loadway4_model.getContractnumber(), a_bm_loadway4_model.getAmount(), a_bm_loadway4_model.getChannel(), a_bm_loadway4_model.getOrig_drn(), a_bm_loadway4_model.getRest_amount()});
    }

    public List getContractNumberList() {
        return this.jdbcTemplate.queryForList("select contract_number from fbu_wm.fbi_buf_unv_contract");
    }

}







